<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>DOM对象转jQuery对象</h1>
    <ul>
        <li>$(DOM对象)</li>
        <li>$(DOM可迭代对象)</li>
        <li>$(html字符串)</li>
    </ul>
    <div class="div1">div1</div>
    <div class="div2">div2</div>
    <div class="div2">div2</div>
</body>
<script src="../jquery-3.6.0.min.js"></script>
<script>
    // 获取DOM对象
    let div1 = document.querySelector(".div1");
    // 转jQuery对象
    let $div1 = $(div1);

    // attr方法相当于setAttribute()和getAttribute()方法
    // 一个参数：获取
    console.log($div1.attr("class"));
    // 二个参数：设置
    $div1.attr("id","div1");
    // 删除属性
    // $div1.removeAttr("id")

    let divs = document.querySelectorAll(".div2");
    let $divs = $(divs);
    // css方法，第二种调用方法，传入两个参数，分别是属性名，属性值
    $divs.css("color","#f00");
</script>
</html>